#ifndef CONFIG_H_INCLUDED
#define CONFIG_H_INCLUDED

#include <string>
#include <vector>

namespace Oribi
{
    class ConfigFile
    {
    public:
        ConfigFile(): fileName(""), ini(0){}
        ConfigFile(std::string fname);

        int   geti(std::string section, std::string key, int   defVal = 0);
        long  getl(std::string section, std::string key, long  defVal = 0);
        float getf(std::string section, std::string key, float defVal = 0);
        bool  getb(std::string section, std::string key, bool  defVal = false);
        std::string gets(std::string section, std::string key, std::string defVal = "");

        bool put(std::string section, std::string key, int val);
        bool put(std::string section, std::string key, long val);
        bool put(std::string section, std::string key, float val);
        bool put(std::string section, std::string key, bool val);
        bool put(std::string section, std::string key, std::string val);

        std::string getFileName() const;
        void setSourceFile(std::string);
    private:
        std::string fileName;
        minIni *ini;
    };

    class ConfContext
    {
    public:
        ConfContext();

        int initialise();

        ConfigFile *getFile(std::string name);
        ConfigFile *addFile(std::string name);

        int   geti(std::string file, std::string section, std::string key, int defVal = 0);
        long  getl(std::string file, std::string section, std::string key, long defVal = 0);
        float getf(std::string file, std::string section, std::string key, float defVal = 0);
        bool  getb(std::string file, std::string section, std::string key, bool  defVal = false);
        std::string gets(std::string file, std::string section,
                         std::string key, std::string defVal = "");

        bool put(std::string file, std::string section, std::string key, int val);
        bool put(std::string file, std::string section, std::string key, long val);
        bool put(std::string file, std::string section, std::string key, float val);
        bool put(std::string file, std::string section, std::string key, bool val);
        bool put(std::string file, std::string section, std::string key, std::string val);
    private:
        std::vector<ConfigFile> files;
    };
}

#endif // CONFIG_H_INCLUDED
